package com.yjhb.android.sbz.adapter.taskmanage;

import android.content.Context;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;

import com.yjhb.android.sbz.R;
import com.yjhb.android.sbz.entity.ManagerTask;
import com.jojo.android.zxlib.base.BaseRecyclerAdapter;

/**
 * 创建者 zx
 * 创建时间 2020/12/9 17:36
 */
public class TaskManagerSuspendAdapter extends BaseRecyclerAdapter<TaskManagerSuspendAdapter.TaskManagerSuspendHolder, ManagerTask> {
    private final String TAG = "TaskManagerSuspendAdapter";

    public TaskManagerSuspendAdapter(Context context) {
        super(context);
    }

    @Override
    protected TaskManagerSuspendHolder getHolder(View v) {
        return new TaskManagerSuspendHolder(v);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.item_task_manager_suspend;
    }

    @Override
    public void onBindViewHolder(@NonNull TaskManagerSuspendHolder taskManagerSuspendHolder, final int i) {
        taskManagerSuspendHolder.name_tv.setText(entity.getTask().getName());
        taskManagerSuspendHolder.money_tv.setText("（" + entity.getTask().getMoney() + "元）");
        taskManagerSuspendHolder.watch_tv.setText("浏览次数:" + entity.getQueryCount() + "次");
        taskManagerSuspendHolder.total_tv.setText("悬赏名额：" + entity.getTask().getMaxStock() + "个");
        taskManagerSuspendHolder.success_tv.setText("已完成：" + entity.getTask().getSuccess() + "个");
        taskManagerSuspendHolder.last_num_tv.setText("" + entity.getTask().getCurrentStock() + "个");
        taskManagerSuspendHolder.publish_tv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (itemClickListener != null) {
                    itemClickListener.onViewClick(v, "restore", i, entity);
                }
            }
        });
    }


    class TaskManagerSuspendHolder extends RecyclerView.ViewHolder {

        TextView name_tv;
        TextView money_tv;
        TextView watch_tv;
        TextView total_tv;
        TextView success_tv;
        TextView last_num_tv;
        TextView publish_tv;

        public TaskManagerSuspendHolder(@NonNull View itemView) {
            super(itemView);
            name_tv = itemView.findViewById(R.id.name_tv);
            money_tv = itemView.findViewById(R.id.money_tv);
            watch_tv = itemView.findViewById(R.id.watch_tv);
            total_tv = itemView.findViewById(R.id.total_tv);
            success_tv = itemView.findViewById(R.id.success_tv);
            last_num_tv = itemView.findViewById(R.id.last_num_tv);
            publish_tv = itemView.findViewById(R.id.publish_tv);
        }
    }


}
